package com.zzty.txj1.dao;



import com.zzty.txj1.entity.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SelfExanMapper {
    @Select("select * from question")
    public List<Question>getQuestion();

    @Select("select count(*) from question")
    public Integer getQuestionCount();

    @Select("select * from user where id=#{id}")
    public User getUserName(Integer id);

    @Insert("insert into question (content) values (#{content})")
    public Integer addQuestion(Question question);

    @Insert("insert into selfExam (questionId,date,clazzId)values (#{questionId},#{date},#{clazzId})")
    public Integer submitQuestion(SelfExam selfExam);

    @Select("select id from selfExam where classId=#{classId} and date=#{date}")
    public Integer getId(SelfExam selfExam);

    @Select("select userId from selfExamTransaction where selfExamId=#{selfExamId}")
    public List<Integer> getUserIds(Integer id);

    @Select("select * from selfExamTransaction where selfExamId=#{selfExamId} and userId=#{userId}")
    public SelfExamTransaction getinfo(SelfExamTransaction selfExamTransaction);

    @Update("update selfExamTransaction set score=#{score} , comment=#{comment} where userId=#{userId} and selfExamId=#{selfExamId}")
    Integer updateSelfExamTransaction(SelfExamTransaction selfExamTransaction);

    @Select("select id from user where name=#{name}")
    Integer getUserId(String name);

    @Update("update selfExam set winnerId=#{winnerId} where  id=#{id}")
    Integer updateSelfExam(SelfExam selfExam);
}
